
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.ArrayList,
                 com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.users.Functionality"%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/addNewSalesPerson.do"/>

<html:html locale="true">

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js">
</script>

<script language='javascript'>
function save()
{
    var errors = '';
    var salesperson = document.addNewSalesPersonForm.newSalesPerson.value;
    var email       = document.addNewSalesPersonForm.email;
    var salesPercent  = document.addNewSalesPersonForm.salesPercent;
     if( salesperson.value != '')
    {
            if( salesperson.trim().length == 0)
            {
                errors = errors + "<li> Please enter Sales Person name ";
            }

    }
    //added by varma 29 jul 2004 to restrict double quote in Sales Person name
    if( salesperson.indexOf('"') >= 0 )
    {
          errors = errors + "<li> Please enter a valid <bean:message key="label.sales.quotation.salesPerson"/> name";
          document.addNewSalesPersonForm.newSalesPerson.select();
          document.addNewSalesPersonForm.newSalesPerson.focus();

    }
    if (!isValidMailID(email.value,email,"N"))
    {
        errors = errors + "<li> Enter a Valid Email ID";
        email.select();
        email.focus();
    }
    if(check_char_position4(salesPercent.value) || (is_Sp_Characters_frieght(salesPercent.value) == false) )
    {
        errors = errors +'<br>' + "<li>  Please enter a valid Sales Percent";
        salesPercent.select();
    }

    if(errors != '')
    {
        var inf = document.getElementById("infoMessagesId");
        inf.innerHTML = '';
        var err = document.getElementById("errorMessagesId");
        err.innerHTML = '';

        var pa=document.getElementById("errors");
        pa.innerHTML = errors;
        return false;
    }

   //var customerId = window.opener.document.customerForm['customer.customerId'].value;
   var oldSalesPerson = document.addNewSalesPersonForm.oldSalesPerson.value;
   if ( oldSalesPerson == '' )
   {
        document.addNewSalesPersonForm.action = '<%=chipTracContext%>/addNewSalesPerson.do?action=insertSalesPerson';
   }
   else
   {
        document.addNewSalesPersonForm.action = '<%=chipTracContext%>/addNewSalesPerson.do?action=editSalesPerson';
   }
   return true;
    //document.addNewSalesPersonForm.submit();
}
function reset(){
    document.addNewSalesPersonForm.reset();
}

function closeWindow(form) {
    window.opener.document.salesPerson_relationship.submit();
 	window.close();
}

</script>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor='#ffffff' leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<!-- from here your body starts -->

<html:form name="addNewSalesPersonForm" type="com.scalar.chiptrack.sales.forms.AddNewSalesPersonForm" action="/addNewSalesPerson.do?action=insertSalesPerson" onsubmit="javascript:return save();" scope="request">


<center><span class="NArialW"> <bean:message key="label.sales.quotation.salesPerson"/> Details</span></center>
<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>
<table border="0" width="90%" align=center>
 <tr><td>
 <table border="0" width="100%" cellspacing='10' cellpadding='2' align='left'>
<tr><td colspan='2' align=right><a href="javascript:closeWindow(document.addNewSalesPersonForm);" onMouseOver="window.status='Click here to close this window';return true" onmouseout="window.status='';return true"><font class='NArialL'>Close this window</font></a></td></tr>
<tr><td colspan='2' id='errorMessagesId'><chiptrack:errors styleClass='NArialL' /></td></tr>
<tr><td colspan='2' id='infoMessagesId'><chiptrack:info styleClass='NArialL' /></td></tr>


    <%--tr><td colspan='2'><img src="<%=chipTracContext%>/jsp/includes/images/spacer/gif" height=10></td></tr--%>
    <tr><td colspan='2' align="left" class='NArialL'><FONT id="errors" styleClass="NArialL" color='FF0000'></FONT></TD></TR>
    <tr><td colspan="2">
        <table border="0">
        <tr>
            <td nowrap><font class="NArialL"><bean:message key="label.sales.quotation.salesPerson"/> Name:<font color=red>*</font>&nbsp;&nbsp;</font>

            </td>
            <td><html:text property="newSalesPerson" name="addNewSalesPersonForm"  size="23" maxlength="<%=ConfigManager.getProperty(ConfigManager.SALESPERSON_NAME_MAX_LENGTH)%>" styleClass="txfield"/>
            <html:hidden property="oldSalesPerson"/>
            <input type="hidden" name="salesPersonId" value="<bean:write name="addNewSalesPersonForm" property="salesPersonId"/>">
            </td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
        <td width="20%" ><font class="NArialL" >Region:</font></td>
        <td width="20%" >
                <html:select name="addNewSalesPersonForm" property="regionId" styleClass="txfield" >
                <html:option value="" >--select Region--</html:option>
                <html:options collection="regions" property="value" labelProperty="label"/>

            </html:select>
         </td>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
        </tr>
        <tr>
            <td width="20%"><font class="NArialL" >Address 1:</font></td>
            <td width="20%"><html:text property="address1" name="addNewSalesPersonForm" size="23" styleClass="txfield" maxlength="50"/></td>
            <td width="8%">&nbsp;</td>
            <td width="20%"><font class="NArialL" >Address 2:</font></td>
            <td width="32%"><html:text property="address2" name="addNewSalesPersonForm" size="23" styleClass="txfield" maxlength="50"/></td>
          </tr>
           <tr>
            <td width="20%"><font class="NArialL" >Address 3:</font></td>
            <td width="20%"><html:text property="address3" name="addNewSalesPersonForm" size="23" styleClass="txfield" maxlength="50"/></td>
            <td width="8%">&nbsp;</td>
            <td width="20%"><font class="NArialL" >Address 4:</font></td>
            <td width="32%"><html:text property="address4" name="addNewSalesPersonForm" size="23" styleClass="txfield" maxlength="50"/></td>
          </tr>
          <tr>
            <td width="20%"><font class="NArialL" >City:</font></td>
            <td width="20%"> <html:text property="city" name="addNewSalesPersonForm"  size="23" styleClass="txfield" maxlength="<%=ConfigManager.getProperty(ConfigManager.ADDRESS_CITY_MAX_LENGTH)%>"/></td>
            <td width="8%">&nbsp;</td>
            <td width="20%"><font class="NArialL" >State:</font></td>
            <td width="32%"><html:text property="state" name="addNewSalesPersonForm"  size="23" styleClass="txfield" maxlength="<%=ConfigManager.getProperty(ConfigManager.ADDRESS_STATE_MAX_LENGTH)%>"/></td>
          </tr>
          <tr>
            <td width="20%"><font class="NArialL" >Zip:</font></td>
            <td width="20%"><html:text property="zipCode" name="addNewSalesPersonForm"  size="23" styleClass="txfield" maxlength="<%=ConfigManager.getProperty(ConfigManager.ADDRESS_ZIP_MAX_LENGTH)%>"/></td>
            <td width="8%"></td>
            <td width="20%"><font class="NArialL" >Country:</font></td>
            <td width="32%">
            <html:text property="country" size="23" name="addNewSalesPersonForm"  styleClass="txfield" maxlength="50"/>
            </td>
          </tr>
          <tr>
            <td width="20%"><font class="NArialL" >Phone No:</font></td>
            <td width="20%"><html:text property="phoneNumber" name="addNewSalesPersonForm" size="23" styleClass="txfield" maxlength="<%=ConfigManager.getProperty(ConfigManager.ADDRESS_PHONE_MAX_LENGTH)%>" onkeypress='validatePhoneNumber(this)'/></td>
            <td width="8%">&nbsp;</td>
            <td width="20%"><font class="NArialL" >Cell No:</font></td>
            <td width="32%"><html:text property="cellNumber" name="addNewSalesPersonForm" size="23" styleClass="txfield" maxlength="50" onkeypress='validatePhoneNumber(this)'/></td>
          </tr>

          <tr>
            <td width="20%"><font class="NArialL" >Fax No:</font></td>
            <td width="20%"><html:text property="faxNumber" name="addNewSalesPersonForm" size="23" styleClass="txfield" maxlength="<%=ConfigManager.getProperty(ConfigManager.ADDRESS_FAX_MAX_LENGTH)%>" onkeypress='validatePhoneNumber(this)'/></td>
            <td width="8%">&nbsp;</td>
            <td width="20%"><font class="NArialL" >Email:</font></td>
            <td width="32%"><html:text property="email" name="addNewSalesPersonForm"  size="23" styleClass="txfield" maxlength="50"/></td>
          </tr>

          <tr>
            <td width="20%"><font class="NArialL" >Sales Percent:</font></td>
            <td width="20%"><html:text property="salesPercent" name="addNewSalesPersonForm" size="23" styleClass="txfield" maxlength="50" onkeypress="javascript:restrictCharacters(this,3,3)" onkeyup="javascript:restrictAmt(this,3,3)"/></td>
            <td width="8%">&nbsp;</td>
            <td width="20%"></td>
            <td width="32%"></td>
          </tr>

          <tr>
            <td colspan="2" align='left' nowrap><html:checkbox property="salesAckMail" /><FONT class='NArialL'>Receive SalesOrder Acknowledge Mails</FONT></td>
             <td width="8%">&nbsp;</td>
            <td colspan="2" align='left'><html:checkbox property="shipAlerts"  /> <font class="NArialL">Receive Ship Alert Mails</font></td>
          </tr>
          <tr>
            <td colspan="2" align='left' nowrap><html:checkbox property="quoteAckMail" /><FONT class='NArialL'>Receive Quote Acknowledge Mails</FONT></td>
            <td width="8%">&nbsp;</td>
            <td colspan="2" align='left'>&nbsp;</td>
          </tr>
        </table>
    </td></tr>

	<tr align='center'>
        <td colspan='1' nowrap align='right'>
		     <%--<a href="javascript:save()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17" onMouseOver="window.status='Click  to Add Sales Person';return true" onmouseout="window.status='';return true" title="Click here to Add Sales Person"></a> --%>
             <input type=image border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17" onmouseover="window.status='Click to Add <bean:message key="label.sales.quotation.salesPerson"/>';return true" onmouseout="window.status='';return true" title="Click here to Add <bean:message key="label.sales.quotation.salesPerson"/>">
	    </td>
		<td colspan='1' nowrap align='left'>
		     <a href="javascript:reset()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17"  onMouseOver="window.status='Click  to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>
	    </td>
    </tr>

  </table>

  </td></tr>
  <!--tr><td><img height=10 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td></tr-->
  <tr><td >

<!-- DISPLAY ALL USERS STARTS HERE -->

<% ArrayList salesPersons = (ArrayList) request.getAttribute("salesPersons");
	if( salesPersons != null && salesPersons.size() != 0 ) { %>

   <table border="0" width="100%" bordercolor="#FFFFFF" align=center>
    <tr>
        <td width="8%">&nbsp;</td>
        <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><bean:message key="label.sales.quotation.salesPerson"/></font></font></td>
        <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Action</font></font></td>
        <td width="8%">&nbsp;</td>
    </tr>


    <logic:iterate id="SalesPerson" name="salesPersons" type="com.scalar.chiptrack.sales.SalesPerson">

	<% int bgcount = 0;%>
    <% bgcount = bgcount + 1; %>
    <tr>
    <td width="8%">&nbsp;</td>
    <td nowrap width="15%" align="left" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL">
    <bean:write name="SalesPerson" property="salesPerson" /></font></td>
    <td nowrap width="15%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL">
     <logic:equal name="SalesPerson" property="disabled" value="true">
     <a href='<%=chipTracContext%>/addNewSalesPerson.do?salesPersonstatus=disable&salesPersonId=<bean:write name="SalesPerson" property="salesPersonId" />&salesPerson=<%= java.net.URLEncoder.encode(  SalesPerson.getSalesPerson() , "UTF-8" )%>' onMouseOver="window.status='Click to Disable Sales Person';return true" onmouseout="window.status='';return true">Disable</a>
     </logic:equal>
     <logic:equal name="SalesPerson" property="disabled" value="false">
     <a href='<%=chipTracContext%>/addNewSalesPerson.do?salesPersonstatus=activate&salesPersonId=<bean:write name="SalesPerson" property="salesPersonId" />&salesPerson=<%= java.net.URLEncoder.encode(  SalesPerson.getSalesPerson() , "UTF-8" )%>' onMouseOver="window.status='Click to Activate Sales Person';return true" onmouseout="window.status='';return true"><font color='red'>Activate</font></a>
     </logic:equal> &nbsp;&nbsp;
     <a href='<%=chipTracContext%>/addNewSalesPerson.do?action=loadSalesPerson&salesPersonId=<bean:write name="SalesPerson" property="salesPersonId" />' onMouseOver="window.status='Click to Edit Sales Person';return true" onmouseout="window.status='';return true">Edit</a>
     </font>
     </td>
    </tr>


    </logic:iterate>
    <tr><td class="NArialL" colspan=5><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=50></td></tr>
    <tr><td colspan=3 align=center><a href="javascript:closeWindow(document.addNewRepOfficeForm);" onMouseOver="window.status='Click here to close this window';return true"onmouseout="window.status='';return true"><font class='NArialL'>Close this window</font></a></td></tr>

    </table>
	<% } %>

<!-- DISPLAY ALL USERS ENDS HERE -->
                                                            
</td></tr>
</table>
<input type="hidden" name="customerId" value ='<%=request.getParameter("customerId")%>' >

</html:form>



</body>

</html:html>